<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../vue.js"></script>
    <style>
        .div1 {
            width: 300px;
            height: 300px;
            background-color: red;
        }
        .div2 {
            width: 200px;
            height: 200px;
            background-color: blueviolet;
        }
        .div3,
        .div-1 {
            width: 100px;
            height: 100px;
            background-color: yellowgreen;
        }
    </style>
</head>
<body>
    <div id="app">
        <p>表单修饰符 按键修饰符 事件修饰符 系统修饰符</p>
        <!-- 按键修饰符 -->
        <!-- 只有按下某个键才会触发对应的函数,可以绑定回车、退格、26个字母等按键 -->
        <!-- 之前需要绑定keyCode触发，现在可以直接绑定键名 -->
        <input type="text" v-model="val1" @keyup.13="show">

        <!-- 事件修饰符 -->
        <!-- .stop 阻止冒泡 -->
        <div class="div1" @click="fn1('div1')">
            <div class="div2" @click.stop="fn1('div2')">
                <div class="div3" @click="fn1('div3')"></div>
            </div>
        </div>

        <br>
        <!-- .capture 将默认的事件冒泡换成事件捕获，或者说是提高优先级 -->
        <div class="div1" @click="fn1('div1')">
            <div class="div2" @click="fn1('div2')">
                <div class="div3" @click.capture="fn1('div3')"></div>
            </div>
        </div>
        <br>
        <!-- prevent 阻止默认时间 -->
        <div class="div1" @contextmenu.prevent="right"></div>

        <!-- 系统修饰符 系统按键 ctrl tab shift结合其他的键一起按 -->
        <input type="text" @keyup.ctrl.i="fn2">

        <!-- 鼠标修饰符 -->
        <div class="div-1" @click.right="right" @click.middle="middle"></div>
    </div>
    <script>
        let vm = new Vue({
            el: '#app',
            data: {
                val1: ''
            },
            methods: {
                show() {
                    console.log(this.val1);
                },
                fn1(name) {
                    console.log(name);
                },
                right() {
                    console.log('right');
                },
                fn2() {
                    console.log(666);
                },
                middle() {
                    // 鼠标中键
                    console.log('middle');
                }
            }
        })
    </script>
</body>
</html>